Package nz.ac.massey.softwarec.group3.reverseAJAX

Source Code of nz.ac.massey.softwarec.group3.reverseAJAX.ScriptSessionManagerInterfaceTest

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package nz.ac.massey.softwarec.group3.reverseAJAX;

import org.directwebremoting.ScriptSession;
import org.jmock.Expectations;
import nz.ac.massey.softwarec.group3.game.Game;
import org.jmock.integration.junit4.JUnit4Mockery;
import javax.servlet.http.HttpSession;
import org.jmock.Mockery;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;

/**
*
* @author wanting
*/
public class ScriptSessionManagerInterfaceTest {
   
    private Mockery context;
    private HttpSession session;
    private ScriptSession scriptSession;
   
    public ScriptSessionManagerInterfaceTest() {
    }


    @Before
    public void setUp() {
        context=new JUnit4Mockery();
        session=context.mock(HttpSession.class);
        scriptSession=context.mock(ScriptSession.class);
    }
   
    @After
    public void tearDown() {
    }

    /**
     * Test of setScriptSessionGame method, of class ScriptSessionManagerInterface.
     */
    @Test
    public void testSetScriptSessionGame() {
        System.out.println("setScriptSessionGame");
  
        final Game game=new Game("user@gmail.com",1);
        context.checking(new Expectations(){
            {
                one(session).getAttribute("game");
                will(returnValue(game));
            }
        });
       
        Game resultgame=(Game) session.getAttribute("game");
        assertEquals(game,resultgame);
       
  
        context.checking(new Expectations(){
            {
                one(session).getAttribute("email");
                will(returnValue(game.getCreatorEmail()));
            }
        });
       

          final String expectEmail="user@gmail.com";   
          String resultEmail=(String)session.getAttribute("email");
          assertEquals(expectEmail,resultEmail);
       
       
          final String email="user@gmail.com";
         context.checking(new Expectations(){
            {
                one(scriptSession).setAttribute("game", game);
                one(scriptSession).setAttribute("email", email);
            }
        });
       
            scriptSession.setAttribute("email", email);
            scriptSession.setAttribute("game", game);
        
        
    }

}
TOP

Related Classes of nz.ac.massey.softwarec.group3.reverseAJAX.ScriptSessionManagerInterfaceTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.